﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace FourPartHarmony3 {
    class VirtualRectangle : IVirtualChild {
        Rect mBounds;
        UIElement mVisual;

        public VirtualRectangle(Rect bounds) {
            mBounds = bounds;
        }


        public UIElement Visual {
            get { return mVisual; }
        }

        public UIElement CreateVisual(HorizontalVirtualCanvas parent) {
            if (mVisual != null) {
                return mVisual;
            }

            var r = new Rectangle();
            r.Width = mBounds.Width;
            r.Height = mBounds.Height;
            r.Fill = new SolidColorBrush(Colors.Black);

            mVisual = r;
            return mVisual;
        }

        public void DisposeVisual() {
            mVisual = null;
        }

        public Rect Bounds {
            get { return mBounds; }
        }
    }
}
